<?php
if (file_exists('config.php') AND file_exists('install.php')){
	print("Please, remove install.php Then you can remove the first 10 lines of code in the file index.php, but this isn't indispensable.");
	exit;
}
elseif (!file_exists('config.php')){
	header("location: install.php");
}
?>
<?php
//
define('ROOT', getcwd());

// Includo la configurazione
include(ROOT.'/config.php');

// Includo le classi e le funzioni
include(ROOT'/includes/classes/mysql.php');
include(ROOT'/includes/functions/functions.php');

// Istanzio le classi
$db = new MYSQL();

$_GET['action'] = isset($_GET['action']) && !empty($_GET['action']) ? $_GET['action'] : 'index';
switch ($_GET['action']) {
case "write":
	if (!isset($_POST['second']) OR !isset($_POST['text'])){
		include("./".template_folder."/template_header.php");
		include("./".template_folder."/template_write_form.php");
		include("./".template_folder."/template_footer.php");		
	}

	else {
		include("./includes/write.php");
		include("./".template_folder."/template_header.php");
		include("./".template_folder."/template_write_print.php");
		include("./".template_folder."/template_footer.php");
	}
break;

case "read":
	include("./includes/read.php");
	include("./".template_folder."/template_header.php");
	include("./".template_folder."/template_read.php");
	include("./".template_folder."/template_footer.php");
break;

case "page":
	include("./".template_folder."/template_header.php");
	include("./includes/pages_static.php");
	include("./".template_folder."/template_footer.php");
break;

case "is_read":
	include("./includes/is_read.php");
	include("./".template_folder."/template_header.php");
	include("./".template_folder."/template_is_read.php");
	include("./".template_folder."/template_footer.php");
break;

default:
	include("./".template_folder."/template_header.php");
	include("./".template_folder."/template_index.php");
	include("./".template_folder."/template_footer.php");
break;
}
?>
